package com.itheima.socket.udp.demo04;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.util.Scanner;

public class SendDemo04 {

    public static void main(String[] args) throws IOException {
        while (true) {
            MulticastSocket multicastSocket = new MulticastSocket();
            Scanner scanner = new Scanner(System.in);
            String next = scanner.next();
            byte[] bytes = next.getBytes();
            int length = bytes.length;
            InetAddress inetAddress = InetAddress.getByName("224.0.0.1");
            int port = 6666;
            DatagramPacket datagramPacket = new DatagramPacket(bytes, length, inetAddress, port);
//            DatagramPacket datagramPacket = new DatagramPacket(scanner.next().getBytes(), scanner.next().getBytes().length, InetAddress.getByName("224.0.0.1"), 6666);
            multicastSocket.send(datagramPacket);
            multicastSocket.close();
        }
    }

}
